/*
 * ConditionalExpressionDescription.java
 * 
 * last update: 30.01.2010 by Vlad Badoiu
 * 
 * author:	Vlad Badoiu(vladbadoiu@gmail.com)
 *
 * Obs:
 */

package engine;

@SuppressWarnings("serial")
class ConditionalExpressionDescription implements ExpressionDescription
{

	public ConditionalExpressionDescription(ExpressionDescription condition, ExpressionDescription ifTrue, ExpressionDescription ifFalse)
	{
		this.condition = condition;
		this.ifTrue = ifTrue;
		this.ifFalse = ifFalse;
	}

	public Expression instantiate(NameSpace n)throws ParseException
	{
		return new ConditionalExpression(n,
				condition.instantiate(n),
				ifTrue.instantiate(n),
				ifFalse.instantiate(n));
	}
	public ExpressionDescription condition;
	public ExpressionDescription ifTrue;
	public ExpressionDescription ifFalse;

	public String toString(){
		return condition + "? " + ifTrue + " : " + ifFalse;
	}

	public boolean isLeftValue(){
		return false;
	}
}

